package com.example.victory.utils;

import com.cgws.fintech.sdk.common.cache.RedisService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * IM 相关
 */
public class ImUtil {
    private static final Logger logger = LoggerFactory.getLogger(ImUtil.class);

    public static String getBFcid(String phone) {
        // @10000002218:im.icbc.com.cn
//        redisService.getAppKey("1");
        try {
            RedisService redisService=  SpringContextHelper.getBean(RedisService.class);
            String redisPhone= (String) redisService.getRedisTemplate().opsForValue().get("inner-platform-security:syncUserPhone:"+phone);
            if(!StringUtils.isEmpty(redisPhone)) phone=redisPhone;
        }catch (Exception e){
            logger.error("get redis key error, key={},e={}", phone, e);
        }
        return "@b" + phone + ":emp.cgws.com.cn";
    }
}
